/*
 * @Author: your name
 * @Date: 2022-03-17 11:01:41
 * @LastEditTime: 2022-03-17 12:00:40
 * @LastEditors: Please set LastEditors
 * @Description: ��koroFileHeader�鿴���� ��������: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \stm32g030c8t6_485_����keyɾ��gps_procexx\BMS\App_alarm.h
 */
#ifndef __ALARM_H
#define __ALARM_H
#include "includes.h"

typedef enum
{
    LESS = 0,
    MORE
} COMPARE;
typedef union
{
    uint32_t bytes;
    struct
    {
        uint16_t O_V : 1;   // 0
        uint16_t U_V : 1;   //Ƿѹ������ֻҪ��Ƿѹ�ı�������1
        uint16_t O_C_D : 1; // 2	
        uint16_t S_C_D : 1; // 3

        uint16_t U_T_D : 1;    // 4
        uint16_t O_T_M : 1;    // 5
        uint16_t O_C_C : 1;    // 6
        uint16_t U_V_1500 : 1; // 7

        uint16_t O_T_C : 1; // 8
        uint16_t O_T_D : 1; // 9
        uint16_t U_T_C : 1; // 10
        uint16_t C_M_E : 1; // 11

        uint16_t D_M_E : 1;
        uint16_t C_P_Count : 1;
        uint16_t TOTAL_OV : 1;
        uint16_t TOTAL_UV : 1;

        uint16_t NTE_ERR : 1;
		uint16_t O_C_D2 : 1;
        uint16_t RSV : 2;
    } bits;
} AlarmSt;

#define R_HV_Bitnum 0
#define R_UV_Bitnum 1
#define R_OCD_Bitnum 2
#define R_UTD_Bitnum 4
#define R_OTM_Bitnum 5
#define R_OTC_Bitnum 8
#define R_OTD_Bitnum 9
#define R_UTC_Bitnum 10
#define R_OCC_Bitnum 6
#define R_HV_N_Bitnum 16

#define NotSleepAlarmMast 0x036D //��������������
#define SleepAlarmMast (NotSleepAlarmMast ^ 0xffff)

typedef struct
{
    uint8_t alarmFlag;
    uint8_t Times;
    uint8_t ReTimes;
    //�ص�����
    // void    ( *Callback )( void );
} ALARM;
extern ALARM U_V_2700;
extern ALARM U_V_3;
extern ALARM U_V_1500;
extern ALARM U_V_2;
extern ALARM U_V_1;

extern ALARM C_O_C_3;
extern ALARM D_O_C3;
extern ALARM D_O_C2;

extern ALARM C_O_C_HK;	
extern ALARM C_O_C_2;		  //������

extern ALARM O_T_M;
extern ALARM U_T_C;
extern ALARM U_T_D;
extern ALARM C_M_E;
extern ALARM RELAY_E; //relay

extern ALARM D_M_E;
extern ALARM CHG_OV_P_Count;

extern ALARM S_C_D;
extern ALARM D_O_C_BJ;

extern ALARM RELAY_C_O_C;
extern ALARM RELAY_D_O_C;


extern ALARM O_T_C;
extern ALARM O_T_C_2;
extern ALARM O_T_D;
extern ALARM O_T_D_2;

extern ALARM U_T_C;
extern ALARM U_T_C_2;

extern ALARM U_T_D;
extern ALARM U_T_D_2;
extern ALARM U_T_D_3;

extern ALARM O_V_3;
extern ALARM O_V_2;
extern ALARM O_V_1;

extern ALARM TOTAL_OV;
extern ALARM TOTAL_UV;
extern ALARM NTCERR;
extern ALARM O_T_M_2; // mos

extern ALARM VOLDIFF_OVER;
extern AlarmSt userAlarm;
extern AlarmSt shAlarm;
extern ALARM TOTALCUR_OI; //��������
void AlarmFilter(int32_t Value,
                 int32_t FilterValue,
                 int32_t RecoverValue,
                 COMPARE CompareType,
                 ALARM *Buff,
                 uint16_t FilterTimes,
                 uint16_t FilterReTimes);
uint16_t Alarm_Com_Count(void);

void AlarmCheck(void);


#endif
